<?php
/**
 * DynaGrid - The PHP datagrid
 *
 * @package    DynaGrid
 * @author     $Author: keesschepers $
 * @version    $Id: Zend.php 13 2011-02-14 07:23:17Z keesschepers $
 */

ini_set('display_errors',true);
error_reporting(E_ALL);

set_include_path(get_include_path().':/var/www/DynaGrid/:/var/www/Zend/library/');

include_once 'Grid.php';

/**
 * In the following example we are going to use the Zend Framework as a adapter
 * for our datasource in the dynagrid. 
 */
include_once 'Zend/Db.php';

$databaseAdapter = Zend_Db::factory('MySQLi', array(
    'host'     => '127.0.0.1',
    'username' => 'root',
    'password' => '',
    'dbname'   => 'dynagrid'
));

$query = $databaseAdapter->select()
    ->from('products');

/**
 * Set up the Zend Framework plugin. If you make your own plugin
 * make sure the file is included and extends DynaGrid_DataSource_Abstract and
 * implements DynaGrid_DataSource_Plugin_Interface. You could set the plugin in the bootstrap of
 * your application.
 */
include_once 'DataSource/Plugin/Zend.php';
DynaGrid_Grid::registerDataSourcePlugin(new DynaGrid_DataSource_Plugin_Zend());

/**
 * Set up a DynaGrid object and pass thru the database adapter
 * and the query builder object (Zend_Db_Select in this case).
 */
$datagrid = new DynaGrid_Grid($databaseAdapter, $query);
echo $datagrid->getHTML();

?>